<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Like
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: Menus.php 2010-09-07 16:05 idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Like
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Like_Plugin_Menus
{ 
  public function onMenuInitialize_LikeProfileUsers($row)
  {
    $viewer = Engine_Api::_()->user()->getViewer();
    $likeTable = Engine_Api::_()->getDbTable('likes', 'like');
    $userLikeCount = $likeTable->getLikedCount(array('user_id' => $viewer->getIdentity(), 'object' => 'user'));

    if ($userLikeCount){
      return array(
        'label' => 'like_Users <span id="like_users_count">(0)</span>',
        'icon' => 'application/modules/Like/externals/images/user.gif',
        'route' => 'like_club',
        'active' => 1,
        'class' => 'like_profile_users',
        'onClick' => "like.list('users')"
      );
    }

    return false;
  }
  
  public function onMenuInitialize_LikeProfilePages($row)
  {
    if (!Engine_Api::_()->getDbTable('modules', 'core')->isModuleEnabled('page')){
      return false;
    }

    $viewer = Engine_Api::_()->user()->getViewer();
    $likeTable = Engine_Api::_()->getDbTable('likes', 'like');
    $pageLikeCount = $likeTable->getLikedCount(array('user_id' => $viewer->getIdentity(), 'object' => 'page'));

    if ($pageLikeCount){
      return array(
        'label' => 'like_Pages <span id="like_pages_count">(0)</span>',
        'icon' => 'application/modules/Like/externals/images/page.png',
        'route' => 'like_club',
        'class' => 'like_profile_pages',
        'onClick' => "like.list('pages')"
      );
    }

    return false;
  }
}